package com.caih.contacts.controller;

import com.caih.contacts.entity.Employees;
import com.caih.contacts.entity.Result;
import com.caih.contacts.service.WeiXinEmployeesService;
import com.caih.contacts.util.AccessToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class WeiXinEmpController {
    @Autowired
    private WeiXinEmployeesService weiXinEmployeesService;

    @PostMapping("/text")
    public AccessToken text(){
        return weiXinEmployeesService.getAccessToken();
    }
    @PostMapping("/saveWeixin")
    public Result<Employees> saveWeiXin(Employees employees){
        System.out.println(employees.toString());
        return weiXinEmployeesService.createE(employees,weiXinEmployeesService.getAccessToken().getToken());
    }
    @GetMapping("/batchdeleteEmp/{idList}")
    public Result<String> batchdeleteEmp(@PathVariable List<String> idList) {
        Result<String> result = new Result<>();
        result = weiXinEmployeesService.batchDeleteE(idList,weiXinEmployeesService.getAccessToken().getToken());
        return result;
    }

}
